package com.food.foodapi.controller;

import com.food.foodapi.instans.Result;
import com.food.foodapi.mapper.ArticleMapper;
import com.food.foodapi.mapper.UserMapper;
import com.food.foodapi.model.result.Count;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 92110
 */
@RestController
@RequestMapping("/count")
public class CountController {

    @Resource
    private ArticleMapper articleMapper;
    @Resource
    private UserMapper userMapper;

    @GetMapping("/total")
    public Result count() {
        Count count = new Count();
        count.setTotalNum(articleMapper.getArticleNum());
        count.setTodayNum(articleMapper.getTodayNum());
        count.setYesterdayNum(articleMapper.getYesterdayNum());
        count.setUserNum(userMapper.getUserNum());
        return Result.success(count);
    }

}
